{template 'common/header'}
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/css/style.css" />
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<style>
    .type{display: none;}
</style>
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">
            自定义导航>编辑
        </h3>
    </div>
    <div class="panel-body">
        <form id="sign-form" class="form-horizontal" role="form" method="post" action="{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'savemodel','version_id'=>$_GPC['version_id'])}" name="submit" style="padding: 20px 0;">
            <div class="form-group">
                <label for="name" class="col-sm-2 control-label">名称</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="name" id="name" value="{$list['name']}">
                    <input type="hidden" name="id" value="{$list['id']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">图片（75*75）</label>
                <div class="col-sm-8">
                    {php echo tpl_form_field_image('simg',$list['simg']);}
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 control-label">类型</label>
                <div class="col-sm-8">
                    <label class="radio inline">
                        <input type="radio" class="ui-radio" name="type" id="type1" value="1" {if $list['type']==1}checked{/if}>链接
                    </label>
                    <label class="radio inline">
                        <input type="radio" class="ui-radio" name="type" id="type2" value="2" {if $list['type']==2}checked{/if}>客服
                    </label>
                </div>
            </div>
            <div class="form-group type">
                <label class="col-sm-2 control-label">链接</label>
                <div class="col-sm-8">
                    <div class="input-group ">
                        <input type="text" class="form-control"  name="link" value="{$list['link']}">
                        <span class="input-group-btn">
                            <button class="btn btn-default link" type="button" data-toggle="modal" data-target="#sort_link">选择链接</button>
                        </span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-8">
                    {if $list['status']==1}
                    <input type="checkbox" checked class="js-switch" value="1" name="status">
                    {else}
                    <input type="checkbox" class="js-switch" name="status" value="1">
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">排序</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="sort" value="{$list['sort']}">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input type="button" name="submit" class="btn btn-default" value="提交">
                    <a class="btn btn-default" href="{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'])}">返回</a>
                    <input id="res" name="res" type="reset" style="display:none;" />
                </div>
            </div>
        </form>
    </div>
</div>
<!--底部链接选择-->
<div class="modal fade" id="sort_link"><div class="modal-dialog">
    <style>
        #selectUrl .modal-body {padding: 10px 15px;}
        #selectUrl .tab-pane {margin-top: 5px; min-height: 400px; max-height: 400px; overflow-y: auto;}
        #selectUrlTab{margin-bottom: 10px;}
    </style>
    <div class="modal-content">
        <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button">×</button>
            <h4 class="modal-title">选择链接</h4>
        </div>
        <div class="modal-body">
            <ul class="nav nav-tabs" id="selectUrlTab">
                <li role="presentation" class="active"><a href="#sut_shop">页面</a></li>
                <li role="presentation"><a href="#sut_time">文章</a></li>
                <li role="presentation"><a href="#sut_class">分类</a></li>
                <li role="presentation"><a href="#sut_app">小程序</a></li>
            </ul>
            <div class="tab-content">
                <div class="tab-pane active" id="sut_shop">
                    <!--<nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../news/news" class="btn btn-default btn-sm" title="新闻动态">新闻动态</nav>-->
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../contact/contact" class="btn btn-default btn-sm" title="联系我们">联系我们</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../teacher/teacher" class="btn btn-default btn-sm" title="名师简介">名师简介</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../service/index" class="btn btn-default btn-sm" title="所有课程">所有课程</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../sign/sign" class="btn btn-default btn-sm" title="报名缴费">报名缴费</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../store/index" class="btn btn-default btn-sm" title="分校查询">分校查询</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../user/user" class="btn btn-default btn-sm" title="个人中心">个人中心</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../video/video" class="btn btn-default btn-sm" title="视频">视频</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../active/list" class="btn btn-default btn-sm" title="优惠活动">优惠活动</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../coupon/coupon" class="btn btn-default btn-sm" title="优惠券">优惠券</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../cut/list" class="btn btn-default btn-sm" title="砍价">砍价</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../mall/mall" class="btn btn-default btn-sm" title="商城">商城</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../mall/mall?&type=1" class="btn btn-default btn-sm" title="商城">商城拼团</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../mall/mall?&type=2" class="btn btn-default btn-sm" title="商城">商城抢购</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../audio/list" class="btn btn-default btn-sm" title="音频">音频</nav>
                </div>
                <div class="tab-pane" id="sut_time">
                    <iframe width="100%" height="395" frameborder="no" border="0" scrolling="no" allowtransparency="yes" src="{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'article','version_id'=>$_GPC['version_id'])}"></iframe>
                </div>
                <div class="tab-pane" id="sut_class">
                    <iframe width="100%" height="395" frameborder="no" border="0" scrolling="no" allowtransparency="yes" src="{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'pclass','version_id'=>$_GPC['version_id'])}"></iframe>
                </div>
                <div class="tab-pane" id="sut_app">
                    <form class="form-horizontal">
                        <div class="form-group">
                            <label  class="col-sm-2 control-label">小程序 appId</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control"  name="appId" id="appId">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label">页面路径</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control"  name="path" id="path">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <input data-dismiss="modal" type="button" name="app_btn" class="btn btn-default" value="确定">
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button data-dismiss="modal" class="btn btn-default" id="select-close" type="button">关闭</button>
        </div>
        <script>
            var objc='';
            $(function(){
                $(".link").click(function(){
                    objc=this;
                });
                $("#sort_link").find('#selectUrlTab a').click(function(e) {
                    $('#tab').val($(this).attr('href'));
                    e.preventDefault();
                    $(this).tab('show');
                });
                $("#sut_shop").find("nav").click(function(){
                    $(objc).parent().prev().val($(this).attr("data-href"));
                });
                $("input[name='app_btn']").click(function(){
                    var appid=$("input[name='appId']").val();
                    var path=$("input[name='path']").val();
                    if(appid!=""){
                        $(objc).parent().prev().val(appid+','+path);
                    }
                });
            });
        </script>
    </div>
</div></div>
<!--底部链接选择 end-->
<script>
    function vip(){
        if($("#type1").is(":checked")){
            $(".type").show();
        }else{
            $(".type").hide();
        }
    }
    vip();
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js"],function(){
        $(function(){
            $("input[name='submit']").click(function(){
                var data=$(".form-horizontal").serialize();
                $.ajax({
                    type:"post",
                    url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'savemodel','version_id'=>$_GPC['version_id'])}",
                    data:data,
                    dataType:'json',
                    success:function(res){
                        if(res.status==1){
                            if($("input[name='id']").val()==""){
                                $("input[name='res']").click();
                                $("body").find(".img-responsive.img-thumbnail").attr("src","");
                            }
                            swal('操作成功!', '操作成功!', 'success');
                        }else{
                            swal('操作失败!', '操作失败!', 'error');
                        }
                    }
                })
            });
            $("input[name='type']").change(function(){
                vip();
            });
        })
    })
</script>
{template 'common/footer'}